package com.ylx.web.s;

import com.alibaba.fastjson.JSON;
import com.ylx.service.GoodsService;
import com.ylx.service.GoodsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;

@WebServlet("/deleteServlet")
public class DeleteServlet extends HttpServlet {
    private GoodsService goodsService=new GoodsServiceImpl();
    protected void doPost (HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        //1. 接收品牌数据
        BufferedReader br=request.getReader();
        String params = br.readLine();
        //转为Brand对象
        int[] ids = JSON.parseObject(params,int[].class);
        goodsService.delete(ids);
        response.getWriter().write("success");

    }

    protected void doGet (HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        this.doPost(request, response);

    }
}
